package test;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.SmartFactoryBean;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.context.Lifecycle;
import org.springframework.context.SmartLifecycle;
import org.springframework.stereotype.Component;

@Component
public class EntityFactoryBean implements SmartFactoryBean, SmartInitializingSingleton, Lifecycle {
    @Override
    public Object getObject() throws Exception {
        return new Entity(new Entity1());
    }

    @Override
    public Class<?> getObjectType() {
        return Entity.class;
    }

    @Override
    public boolean isEagerInit() {
        return true;
    }

    @Override
    public void afterSingletonsInstantiated() {
        System.out.println("EntityFactoryBean构建完成");
    }

    @Override
    public void start() {
        System.out.println("开启生命周期");
    }

    @Override
    public void stop() {

    }

    @Override
    public boolean isRunning() {
        return false;
    }
}
